using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

public class EnergyBarController:MonoBehaviour {

	[SerializeField] Image image;
	[SerializeField] RectTransform baseTransform;
	[SerializeField] float pixelPerEnergy;
	[SerializeField] TextMeshProUGUI text;

	private void Update() {
		Mob player = Player.instance;
		image.fillAmount=player.energy/player.energyMax;
		Vector2 sizeCurrent = baseTransform.sizeDelta;
		sizeCurrent.x=Player.instance.energyMax*pixelPerEnergy+4;
		baseTransform.sizeDelta=sizeCurrent;
		text.text=$"{Mathf.CeilToInt(Player.instance.energy)}/{Mathf.CeilToInt(Player.instance.energyMax)}";
	}

}
